import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'HomePage',
      redirect: { name: 'LoginPage' }
    },
    {
      path: '/login',
      name: 'LoginPage',
      component: () => import('@/views/login/LoginPage.vue')
    },

    {
      path: '/backend',
      name: 'BackendPage',
      component: () => import('@/views/backend/BackendPage.vue'),
      redirect: { name: 'BackendBlogsList' },

      children: [
        {
          path: 'blogs/list',
          name: 'BackendBlogsList',
          component: () => import('@/views/backend/blogs/ListPage.vue')
        },
        {
          path: 'blogs/edit',
          name: 'BackendBlogsEdit',
          component: () => import('@/views/backend/blogs/EditPage.vue')
        },
        {
          path: 'comments/list',
          name: 'BackendCommentsList',
          component: () => import('@/views/backend/comments/ListPage.vue')
        }
      ]
    },

    {
      path: '/frontend',
      name: 'FrontendPage',
      component: () => import('@/views/frontend/FrontendPage.vue'),

      children: []
    },
    {
      path: '/:pathMatch(.*)*',
      name: 'NotFoundPage',
      component: () => import('@/views/common/NotFound.vue')
    }

  ]
})

export default router
